package com.zhiyou100.crm.service.impl;

import com.zhiyou100.crm.dao.UserDao;
import com.zhiyou100.crm.service.UserService;
import com.zhiyou100.crm.pojo.User;
import com.zhiyou100.crm.util.S_session;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.List;
import java.util.Random;
@Service("userServiceImpl")
public class UserServiceImpl  implements UserService {
//    UserDao userDao =new UserDaoImpl();
    @Autowired
    private UserDao userDao;

    @Override
    public List<User> queryUserByName(User user) throws IOException {
        List<User> users = userDao.queryUserByName(user);
        return users;
    }
    @Override
    public List<User> queryAllUser() throws IOException {
        List<User> users = userDao.queryAllUser();
        return users;
    }

    @Override
    public boolean updateUser(User user) throws IOException {
        boolean b = userDao.updateUser(user);
        if(b)
        {
            return true;
        }else {
            return false;
        }
    }

    @Override
    public int addUser(User user) throws IOException {
        int a = userDao.addUser(user);
        return a;
    }

    @Override
    public boolean deleteUser(int u_id) throws IOException {
        boolean b = userDao.deleteUser(u_id);
        if(b)
        {
            return true;
        }else {
            return false;
        }
    }
}
